const rl = @import("raylib");
const Food = @import("food.zig");
const Map = @import("../map.zig");

const Event = @This();

map: *Map,

pub fn init(map: *Map) *@This() {
    const item = map.allocator.create(@This()) catch @panic("Out of memory");

    item.map = map;

    return item;
}

pub fn deinit(self: *@This()) void {
    self.map.allocator.destroy(self);
}

pub fn gen(self: *@This()) void {
    self.food();
}

const FoodGenSpeed: f32 = 1;
var food_timing: f32 = 0.0;
fn food(self: *@This()) void {
    food_timing += rl.getFrameTime();

    if (food_timing > FoodGenSpeed) {
        _ = Food.init(self.map);
        food_timing = 0.0;
    }
}
